package com.ruoyi.service.impl;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.BaseSignalanalysisInfoForS;
import com.ruoyi.mapper.BaseSignalanalysisInfoForSMapper;
import com.ruoyi.service.IBaseSignalanalysisInfoForSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 信号分析Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-08
 */
@Service
public class BaseSignalanalysisInfoForSServiceImpl implements IBaseSignalanalysisInfoForSService
{
    @Autowired
    private BaseSignalanalysisInfoForSMapper baseSignalanalysisInfoMapper;

    /**
     * 查询信号分析
     * 
     * @param id 信号分析主键
     * @return 信号分析
     */
    @Override
    public BaseSignalanalysisInfoForS selectBaseSignalanalysisInfoById(Long id)
    {
        return baseSignalanalysisInfoMapper.selectBaseSignalanalysisInfoById(id);
    }

    /**
     * 查询信号分析列表
     * 
     * @param baseSignalanalysisInfo 信号分析
     * @return 信号分析
     */
    @Override
    public List<BaseSignalanalysisInfoForS> selectBaseSignalanalysisInfoList(BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        return baseSignalanalysisInfoMapper.selectBaseSignalanalysisInfoList(baseSignalanalysisInfo);
    }

    /**
     * 新增信号分析
     * 
     * @param baseSignalanalysisInfo 信号分析
     * @return 结果
     */
    @Override
    public int insertBaseSignalanalysisInfo(BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        String cap =  baseSignalanalysisInfoMapper.getCapability(baseSignalanalysisInfo.getCaseId(),sysUser.getUserId());
        baseSignalanalysisInfo.setCapability(cap);
        return baseSignalanalysisInfoMapper.insertBaseSignalanalysisInfo(baseSignalanalysisInfo);
    }

    /**
     * 修改信号分析
     * 
     * @param baseSignalanalysisInfo 信号分析
     * @return 结果
     */
    @Override
    public int updateBaseSignalanalysisInfo(BaseSignalanalysisInfoForS baseSignalanalysisInfo)
    {
        return baseSignalanalysisInfoMapper.updateBaseSignalanalysisInfo(baseSignalanalysisInfo);
    }

    /**
     * 批量删除信号分析
     * 
     * @param ids 需要删除的信号分析主键
     * @return 结果
     */
    @Override
    public int deleteBaseSignalanalysisInfoByIds(Long[] ids)
    {
        return baseSignalanalysisInfoMapper.deleteBaseSignalanalysisInfoByIds(ids);
    }

    /**
     * 删除信号分析信息
     * 
     * @param id 信号分析主键
     * @return 结果
     */
    @Override
    public int deleteBaseSignalanalysisInfoById(Long id)
    {
        return baseSignalanalysisInfoMapper.deleteBaseSignalanalysisInfoById(id);
    }

    @Override
    public R updateStatus(List<Integer> id) {
        //提交文件时直接更新状态 提交到指挥员 为2
        for (Integer ids:id) {
            baseSignalanalysisInfoMapper.updateStatus(ids,2);
        }
        return R.ok();
    }
}
